package com.baizhi.service;

import com.baizhi.dao.userDAO;
import com.baizhi.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.UUID;

@Service
@Transactional   //配合事务得到注解
public class UserServiceImpl implements UserService{

    @Autowired
    private userDAO userDAO;


    //1.注册
    @Override
    public void save(User user) {
        user.setId(UUID.randomUUID().toString());  //给id设置自增
        userDAO.save(user);
    }


    //2.登录
    @Override
    public User login(String username, String password) {
        return userDAO.findByUsernameAndPassword(username,password);
    }
}
